<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            height: 5000px;
        }
        /* div{
            height: 150px;
            width: 70px;
            background-color: lightblue;
        } */
        img{
            /* width: 300px;
            height: 450px; */
            position: absolute;
        }
    </style>
</head>
<body>
    <!-- <div id="box1"> -->
        <img src="../img/renwu.png" alt="" id="box1">
    <!-- </div> -->
    <script>
        //获取div
        let box1 = document.getElementById('box1');
        //给box1添加滚轮事件
        box1.addEventListener('mousewheel',(event)=>{
            //获取滚轮滚动方向
            let x = event.wheelDelta;
            // alert(x); //向上滚动为正值，向下滚动为负值
            //判断是否为正，为正则盒子比例缩小，反之
            // alert(box1.clientHeight) //返回当前高度。
            // alert(box1.clientWidth) //
            if(x<0){
                box1.style.height = box1.clientHeight + 10 +'px';
            }else{
                box1.style.height = box1.clientHeight - 10 +'px';
            }
            //如果浏览器自身有滚动条，那么需要取消默认行为
            event.preventDefault();
        },false)
    </script>
</body> 
</html>